{% load static %}
    <!-- Font Awesome Icons -->
    <link rel="stylesheet" href="{% static 'plugins/fontawesome-free/css/all.min.css'  %}">
    <!-- Theme style -->
    <link rel="stylesheet" href="{% static 'plugins/layui/css/layui.css'  %}">
    <link rel="stylesheet" href="{% static 'dist/css/adminlte.min.css'  %}">
{% block content %}
<section class="content">
        <div class="container-fluid">
            <div class="row" style="height: 10px"></div>
            <div class="row">
                <div class="col-sm-12">
                        <div class="card-body">
                            <div class="form-group">
                                <label style="color: #007bff"> 项目名：</label>
                                <input type="text" class="form-control" id="project_name">
                                <input type="text" class="form-control" id="uid" value="{{ uid }}" hidden>
                                <input type="text" class="form-control" id="worker_or_leader" value="{{ worker_or_leader }}" hidden>
                            </div>
                             <div class="form-group">
                                <input class="btn btn-info" style="text-align: center" type="submit" id="submit" value="提交"/>
                            </div>
                </div>
            </div>
            </div>
        </div>
    </section>
{% block custom_js %}
    <!-- jQuery -->
    <script src="{% static 'js/jquery-3.5.1.min.js' %}"></script>
    <script src="{% static 'plugins/layui/layui.js' %}"></script>
<script>
//post提交的csrf认证
$.ajaxSetup({
    data: {csrfmiddlewaretoken: '{{ csrf_token }}' },
});
$(document).ready(function () {
    $("#submit").click(function () {
        //提示用户正在加载
        layui.use('layer',function () {
                var layer =layui.layer;
                layer.msg('正在提交...',{
                    icon:16,
                    shade:0.01,
                });
            })
        msg  = ''
        $.ajax({
            url: '{% url 'login:add_user_project' %}',
            type: 'POST',
            async: true,
            data: {
                'project_name': $("#project_name").val(),
                'uid': $("#uid").val(),
                'worker_or_leader': $("#worker_or_leader").val(),
            },
            //请求成功后执行提醒
            success: function (data) {
                layui.use('layer',function () {
                    var layer=layui.layer;
                    if (data.status === 0){   //如果添加失败，则停留在此
                        layer.alert(info,{
                            icon: 5,
                            skin: 'layer-ext-moon',
                        })
                    }else {
                        layer.alert(data.info,{
                            icon: 1,
                            skin: 'layer-ext-moon',
                            yes: function () {
                                parent.layer.closeAll();
                            }
                        })
                    }
                    })
            }
        })
    });
})
</script>
{% endblock %}
{% endblock %}